//**************************************************************************************************************
// CLASS: Segment
//
// DESCRIPTION
// See comments in Segment.hpp.
//
// AUTHOR INFORMATION
// Kevin R. Burger
//   
// Mailing Address:
// Computer Science & Engineering
// School of Computing, Informatics, and Decision Systems Engineering
// Arizona State University
// Tempe, AZ 85287-8809
//
// Email: burgerk@asu
// Web:   http://kevin.floorsoup.com
//**************************************************************************************************************
#include "Segment.hpp"

//==============================================================================================================
// PUBLIC FUNCTION MEMBERS
//==============================================================================================================

//--------------------------------------------------------------------------------------------------------------
// Default ctor.
//
// IMPORTANT:
// Study the constructors in the DataSegment and TextSegment derived classes to see how this ctor gets called.
// Very, very important.
//--------------------------------------------------------------------------------------------------------------
Segment::Segment(Address const pAddress): mAddress(pAddress)
{
}

//--------------------------------------------------------------------------------------------------------------
// Copy ctor.
//--------------------------------------------------------------------------------------------------------------
Segment::Segment
    (
    Segment const& pSegment
    )
{
    Copy(pSegment);
}

//--------------------------------------------------------------------------------------------------------------
// Dtor.
//--------------------------------------------------------------------------------------------------------------
Segment::~Segment
    (
    )
{
}

//--------------------------------------------------------------------------------------------------------------
// GetAddress()
//
// DESCRIPTION:
// mAddress accessor function.
//--------------------------------------------------------------------------------------------------------------
int Segment::GetAddress()
    const
{
    return mAddress;
}

//--------------------------------------------------------------------------------------------------------------
// operator=()
//--------------------------------------------------------------------------------------------------------------
Segment& Segment::operator=
    (
    Segment const& pSegment
    )
{
    if (this != &pSegment) Copy(pSegment);
    return *this;
}

//--------------------------------------------------------------------------------------------------------------
// SetAddress()
//
// DESCRIPTION:
// mAddress mutator function.
//--------------------------------------------------------------------------------------------------------------
void Segment::SetAddress
    (
    Address const pAddress
    )
{
    mAddress = pAddress;
}

//==============================================================================================================
// PROTECTED FUNCTIONS
//==============================================================================================================

//--------------------------------------------------------------------------------------------------------------
// Copy()
//
// DESCRIPTION:
// Makes 'this' Segment a copy of pSegment.
//--------------------------------------------------------------------------------------------------------------
void Segment::Copy(Segment const& pSegment)
{
    SetAddress(pSegment.GetAddress());
}

//==============================================================================================================
// PRIVATE FUNCTIONS
//==============================================================================================================
